import os
from collections import OrderedDict

from django.conf import settings
from django.template import loader

from goods.utils import get_categories
from goods.models import GoodsChannel


def generate_static_goods_list():
	"""
	商品分类数据静态化操作
	"""
	print('---generate_static_goods_list---')

	categories = get_categories()

	context = {
		'categories': categories,
		'nginx_url': 'http://192.168.19.131:8888'
	}

	template = loader.get_template('list.html')
	static_html = template.render(context)

	save_path = os.path.join(settings.GENERATED_STATIC_HTML_FILES_DIR, 'list.html')

	with open(save_path, 'w', encoding='utf-8') as f:
		f.write(static_html)
